package com.command.center.pucms.pucmsgateway.controller;


import com.command.center.pucms.pucmsgateway.domain.User;
import com.command.center.pucms.pucmsgateway.service.IUserService;
import com.command.platform.core.page.PageRequest;
import com.command.platform.core.page.PageResponse;
import com.command.platform.core.result.Result;
import com.command.platform.core.result.ResultCode;
import com.command.platform.core.utils.MessageUtil;
import com.command.platform.mvc.controller.PageController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户接口
 *
 * @author zlb
 * @since 2021-04-25
 */
@Api(tags = "用户api业务接口")
@RestController
@RequestMapping("/user")
public class UserController extends PageController {

    @Autowired
    private IUserService userService;

    @ApiOperation(value = "根据条件查询用户列表", notes = "根据条件查询用户列表")
    @GetMapping(value = "/list")
    public Result list(PageRequest pageRequest, @RequestBody User user) {
        PageResponse<User> userpage = userService.page(this.getPageResponse(pageRequest), user);
        return Result.success(ResultCode.SUCCESS.code(), ResultCode.SUCCESS.message());
    }


    @ApiOperation(value = "根据条件查询用户列表", notes = "根据条件查询用户列表")
    @GetMapping(value = "/list1")
//    //添加用户的按钮权限
    @RequiresPermissions("user:list")
    @RequiresRoles("sysadmin")
    public Result list1() {
        System.out.println("hello world");
        return Result.success(MessageUtil.get(ResultCode.SUCCESS.message()));
    }
}